package leetcode.offer0006;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import leetcode.helper.tree.ListNode;

class Solution {
	public int[] reversePrint(ListNode head) {
		int size = 0;
		ListNode p = head;
		while (p != null) {
			p = p.next;
			size++;
		}
		int[] ans = new int[size];
		for (int i = size - 1; i >= 0; i--) {
			ans[i] = head.val;
			head = head.next;
		}
		return ans;
	}

	public static void main(String[] args) {
		Map<String, String> map = new HashMap<>();
		map.put("hello", "world");
		for (Entry<String, String> entry : map.entrySet()) {
			String key = entry.getKey();
			String value = entry.getValue();
			System.out.println(key + " " + value);
		}
	}
}
